﻿using System.Collections;

namespace TI_BLE_HCI_ClientLib.Controllers.GATT_Entities
{
    public class GATT_Service
    {
        ArrayList _characteristics = new ArrayList();
        ushort _endHandle;
        bool _isPrimaryService = true;

        ushort _startHandle;

        ushort _value;

        public GATT_Service(ushort serviceValue, bool isPrimaryService = true)
        {
            _value = serviceValue;
            _isPrimaryService = isPrimaryService;
        }

        public ArrayList Characteristics
        {
            get { return _characteristics; }
        }

        public ushort EndHandle
        {
            get { return _endHandle; }
            set { _endHandle = value; }
        }

        public bool IsPrimaryService
        {
            get { return _isPrimaryService; }
            set { _isPrimaryService = value; }
        }

        public ushort ServiceValue
        {
            get { return _value; }
        }
        public ushort StartHandle
        {
            get { return _startHandle; }
            set { _startHandle = value; }
        }
        public GATT_Characteristic AddCharacteristic(string identifier, GATT_Characteristic.PermissionsEnum permissions, GATT_Characteristic.ValueTypeEnum valueType)
        {
            var characteristic = new GATT_Characteristic(identifier, permissions, valueType);

            _characteristics.Add(characteristic);

            return characteristic;
        }

        public GATT_Characteristic AddCharacteristic(string identifier, GATT_Characteristic.PermissionsEnum permissions, GATT_Characteristic.ValueTypeEnum valueType, string userDescription)
        {
            var characteristic = new GATT_Characteristic(identifier, permissions, valueType, userDescription);

            _characteristics.Add(characteristic);

            return characteristic;
        }
    }
}
